<template>
  <div class="box">
    <!-- 头部 -->
    <div class="header">
      <van-icon name="arrow-left" @click="goBack" />
      <span>注册</span>
    </div>
    <div class="content">
      <div class="photo"> 
        <section><van-icon name="photo-fail" /></section>
        <section> 请设置登录密码</section>
      </div>

      <van-cell-group :border="false">
        <van-field v-model="value" type="password" placeholder="请设置至少6位登录密码" />
      </van-cell-group>
      <p>密码强度校验，最少6位，包括至少1个大写字母，1个小写字母，1个数字</p>
      <van-button
        round
        type="info"
        color="linear-gradient(to right, #ff60349d, #ee0a2596)"
        @click="finish"
        >完成</van-button
      >
    </div>
  </div>
</template>

<script>
import axios from 'axios';

export default {
    name:"pwd",
    data(){
        return {
            value:"",

        }
    },
    methods:{
    goBack() {
      this.$router.back();
    }, 
    finish(){
      var pattern = /^(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{6,18}$/
      if(!pattern.test(this.value)){
        Toast({
            message:"密码设置不符合规范"
        })
      }else{
        axios({
            method:"post",
            url:"/api/user/dofinishregister",
            data:{
                tel:localStorage.getItem("tel"),
                password:this.value
            }
        }).then((res)=>{
            if(res.data.code=="200"){
                this.$router.push("/Login")
                // 移出掉tel
                localStorage.removeItem("tel")
            }
        })
      }
    }
    }
};
</script>

<style scoped>
.header {
  height: 3.5rem;
  text-align: center;
  font-size: 1.3rem;
  line-height: 3.5rem;
  border-bottom: 2px solid gray;
}
.header .van-icon {
  float: left;
  padding-left: 10px;
  line-height: 3.5rem;
  color: rgb(24, 24, 64);
}
.content {
  margin: 3rem 1.5rem;
}
.van-button {
  margin: 1rem;
  width: 90%;
}
.van-field {
  border-bottom: 1px solid #efefef;
}
p {
  color: black;
  font-size: 12px;
  margin-top: 10px;
}
.photo{
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
} 
.photo section :nth-child(1){
    font-size: 30px;
    color: #efefef;
    margin:30px 0 40px;
}
.photo section :nth-child(2){
    font-size: 12px;
    margin-bottom: 30px;
}
</style>